#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>



int Cmp_by_int(const void* e1, const void* e2)
{

	return(*(int*)e1- *(int*)e2);

}
void Swap(char* buff1, char* buff2, int wideth)
{
	int i = 0;
	for (i = 0; i < wideth; i++)
	{
		char temp = *buff1;
		*buff1 = *buff2;
		*buff2 = temp;
		buff1++;
		buff2++;
	}

}


void Bubble_sort(void* base,int sz,int Wideth,int (*Cmp)(const void *pf1,const void *pf2))
{
	int i = 0;
	for (i = 0; i < sz-1; i++)
	{
		int flag = 1;
		int j = 0;
		for(j=0;j<sz-1-i;j++)
		{
			if (Cmp((char*)base+j*Wideth, (char*)base + (j + 1) * Wideth) > 0)
			{
				Swap((char*)base+j * Wideth, (char*)base + (j + 1) * Wideth,Wideth);
				flag = 0;
			}
		}
		if (flag == 1)
		{
			break;
		}
		
	}
	




}

int main()
{
	//system("pause");
	int Arr[] = { 9,8,7,6,5,4,3,2,1,0 };
	int sz = sizeof(Arr)/sizeof(Arr[0]);
	Bubble_sort(Arr, sz, sizeof(Arr[0]), Cmp_by_int);
	int k = 0;
	for (k = 0; k < sz; k++)
	{
	
		printf("%d", Arr[k]);
	}
	return 0;
	
	
}